﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUpload.aspx.cs" Inherits="FileUpload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="Stylesheet" href="js/uploadify/uploadify.css" />

    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

    <script type="text/javascript" src="js/uploadify/swfobject.js"></script>

    <script type="text/javascript" src="js/uploadify/jquery.uploadify.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            //            $("#<%=ddlfileType.ClientID %>").change(function() {
            //                var folder = "UpFiles/" + $("#<%=ddlfileType.ClientID %> option:selected").text();
            //                $("#hidFolder").val(folder);
            //                $("#hidFileType").val($("#<%=ddlfileType.ClientID %> option:selected").val());
            //            });
            $("#uploadify").uploadify({
                'uploader': 'js/uploadify/uploadify.swf',
                'script': 'ashx/UploadHandler.ashx',
                'cancelImg': 'js/uploadify/cancel.png',
                'folder': $('#hidFolder').val(),
                'queueID': 'fileQueue',
                'sizeLimit': '10485760', //10M
                'auto': false,
                'multi': true,
                'queueSizeLimit': 2,
                'fileDesc': 'select your document',
                'fileExt': '*.*',
                'method': 'GET',
                'scriptData': { 'type': $('#hidFileType').val(), 'owner': $('#hidUploadUser').val() },
                'onAllComplete': function(e, data) {
                    alert("上传文件：" + data.filesUploaded + "\r\n" +
                          "出错文件：" + data.errors + "\r\n" +
                          "文件总量：" + data.allBytesLoaded + "\r\n" +
                          "上传速率：" + data.speed
                            );
                },
                'onError': function(event, queueId, fileObj, errorObj) {
                    alert("上传文件：" + queueId + "\r\n" +
                          "错误类型：" + errorObj.type + "\r\n" +
                          "错误信息：" + errorObj.info
                            );
                }
            });
        });
    
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p>
            <asp:DropDownList ID="ddlfileType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlfileType_SelectedIndexChanged">
            </asp:DropDownList>
        </p>
        <p>
            上传文件：
        </p>
        <p>
            <input type="file" name="uploadify" id="uploadify" />
            <a href="javascript:$('#uploadify').uploadifyUpload()" id="upfile" runat="server">上传文件</a>
        </p>
        <div id="fileQueue">
        </div>
        <a id="dw" runat="server"></a>
    </div>
    <input id="hidFileType" type="hidden" runat="server" />
    <input id="hidUploadUser" type="hidden" runat="server" />
    <input id="hidFolder" type="hidden" runat="server" />
    </form>
</body>
</html>
